<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />   
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
        	var fceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomereshop');
        	var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
			var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
						
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
								                
                var idValue = getPrarmeterValue(window.location, 'id');
                var startPage = getPrarmeterValue(window.location, 'startPage');
                var customerForm = new Ext.FormPanel({
                    labelAlign: 'left',
                    labelWidth: 120, 
                    url: '../../servlet/BiFranceCustomerEshopServlet?action=1',
                    frame: true,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'accountNumber',
                        mapping: 'accountNumber'
                    }, {
                        name: 'email',
                        mapping: 'email'
                    }, {
                        name: 'title',
                        mapping: 'title'
                    }, {
                        name: 'firstName',
                        mapping: 'firstName'
                    }, {
                        name: 'lastName',
                        mapping: 'lastName'
                    }, {
                        name: 'streetAddress',
                        mapping: 'streetAddress'
                    }, {
                        name: 'phoneNumber',
                        mapping: 'phoneNumber'
                    }, {
                        name: 'postalCode',
                        mapping: 'postalCode'
                    }, {
                        name: 'city',
                        mapping: 'city'
                    }, {
                        name: 'country',
                        mapping: 'country'
                    }, {
                        name: 'bTitle',
                        mapping: 'bTitle'
                    }, {
                        name: 'bFirstName',
                        mapping: 'bFirstName'
                    }, {
                        name: 'bLastName',
                        mapping: 'bLastName'
                    }, {
                        name: 'bStreetAddress',
                        mapping: 'bStreetAddress'
                    }, {
                        name: 'bPhoneNumber',
                        mapping: 'bPhoneNumber'
                    }, {
                        name: 'bPostalCode',
                        mapping: 'bPostalCode'
                    }, {
                        name: 'bCity',
                        mapping: 'bCity'
                    }, {
                        name: 'bCountry',
                        mapping: 'bCountry'
                    }]),
                    title: fcMessage.get('ui.francecustomereshop.edittitle'),
                    bodyStyle: 'padding:5px 5px 5px 5px',
                    
                    items: [{
                    	id: 'eshopSet1',
                        xtype: 'fieldset',
                        collapsible: true,
                        title: fcMessage.get('ui.francecustomer.addressdelivery'),
                        autoHeight: true,
                        items: [{
                            id: 'franceCustomerEshopId',
                            name: 'id',
                            xtype: 'hidden'
                        },{
                             layout: 'column',
                             items: [{
                                 columnWidth: .33,
                                 layout: 'form',
                                 items: [{
                                	 html:'<div>&nbsp;</div><br/>' 
                                 },{
    								 id: 'title',
                                     name: 'title',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.title'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 },{
    								 id: 'postalCode',
    	                                name: 'postalCode',
    	                                fieldLabel: fceMessage.get('ui.francecustomereshop.postcode'),
    	                                xtype: 'textfield',
    	                                anchor: '86%',
    									 width: '90%',
    	                                allowBlank: false,
    	                                blankText: message.get('message.edit.noblank'),
    	                                maxLength: 64
    	                            }]
    				
    						 },{
                                 columnWidth: .33,
                                 layout: 'form',
                                 items: [{
    								 id: 'email',
                                     name: 'email',
                                     fieldLabel: 'E-Mail',
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                     maxLength: 64
                                 },{
    								 id: 'firstName',
                                     name: 'firstName',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.fname'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                     maxLength: 64
                                 },{
    								 id: 'city',
                                     name: 'city',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.city'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
    								 id: 'accountNumber',
                                     name: 'accountNumber',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.account'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 },{
    								 id: 'lastName',
                                     name: 'lastName',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.lname'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                     maxLength: 64
                                 },{
    								 id: 'country',
                                     name: 'country',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.country'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						}]
    					},{
                            layout: 'column',
                            items: [{
                                columnWidth: .66,
                                layout: 'form',
                                items: [{
    								 id: 'streetAddress',
                                    name: 'streetAddress',
                                    fieldLabel: fceMessage.get('ui.francecustomereshop.address'),
                                    xtype: 'textarea',
                                    anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                    maxLength: 64
                                }]
    				
    						},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
    								 id: 'phoneNumber',
                                     name: 'phoneNumber',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.phonemumber'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						 }]
    					}]
                     },{
                    	id: 'eshopSet2',
                        xtype: 'fieldset',
                        collapsible: true,
                        title: fcMessage.get('ui.francecustomer.addressbill'),
                        autoHeight: true,
                        items: [{
                             layout: 'column',
                             items: [{
                                 columnWidth: .33,
                                 layout: 'form',
                                 items: [{
    								 id: 'bTitle',
                                     name: 'bTitle',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.title') + '&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../images/icons/paste_plain.png" style="cursor: hand;" onclick="copyAddress();">',
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 },{
    								 id: 'bPostalCode',
    	                                name: 'bPostalCode',
    	                                fieldLabel: fceMessage.get('ui.francecustomereshop.postcode'),
    	                                xtype: 'textfield',
    	                                anchor: '86%',
    									 width: '90%',
    	                                allowBlank: false,
    	                                blankText: message.get('message.edit.noblank'),
    	                                maxLength: 64
    	                            }]
    				
    						 },{
                                 columnWidth: .33,
                                 layout: 'form',
                                 items: [{
    								 id: 'bFirstName',
                                     name: 'bFirstName',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.fname'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                     maxLength: 64
                                 },{
    								 id: 'bCity',
                                     name: 'bCity',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.city'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
    								 id: 'bLastName',
                                     name: 'bLastName',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.lname'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                     maxLength: 64
                                 },{
    								 id: 'bCountry',
                                     name: 'bCountry',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.country'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						}]
    					},{
                            layout: 'column',
                            items: [{
                                columnWidth: .66,
                                layout: 'form',
                                items: [{
    								 id: 'bStreetAddress',
                                    name: 'bStreetAddress',
                                    fieldLabel: fceMessage.get('ui.francecustomereshop.address'),
                                    xtype: 'textarea',
                                    anchor: '86%',
    								 width: '90%',
    								 allowBlank: false,
                                    maxLength: 64
                                }]
    				
    						},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
    								 id: 'bPhoneNumber',
                                     name: 'bPhoneNumber',
                                     fieldLabel: fceMessage.get('ui.francecustomereshop.phonemumber'),
                                     xtype: 'textfield',
                                     anchor: '86%',
    								 width: '90%',
                                     allowBlank: false,
                                     blankText: message.get('message.edit.noblank'),
                                     maxLength: 64
                                 }]
    				
    						 }]
    					}]
                     }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
                            if (customerForm.getForm().isValid()) {
                                customerForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                        //alert(form);
										
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        customerForm.getForm().reset();
                                        //customerForm.show();
                                    },
                                    failure: function(form, action){
                                        //alert(form);
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                        //customerForm.show();
                                    }
                                });
                            }
                        }
                    },{
						text: message.get('message.edit.reset'),
						handler: function(){
							customerForm.getForm().reset();
						}
					}, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'france_customer_eshop_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'france_customer_eshop_list.html';
                            }
                        }
                    }]
                });
				
				customerForm.render('franceCustomer');
	
		
				if(idValue != null){
					document.getElementById('franceCustomerEshopId').value = idValue;
					customerForm.getForm().load({url:'../../servlet/BiFranceCustomerEshopServlet?action=3&id=' + idValue, waitMsg:Ext.LoadMask.prototype.msg});
				}
            });
            
            var copyAddress = function(){
            	Ext.getCmp('bTitle').setValue(Ext.getCmp('title').getValue());
            	Ext.getCmp('bFirstName').setValue(Ext.getCmp('firstName').getValue());
            	Ext.getCmp('bLastName').setValue(Ext.getCmp('lastName').getValue());
            	Ext.getCmp('bStreetAddress').setValue(Ext.getCmp('streetAddress').getValue());
            	Ext.getCmp('bPhoneNumber').setValue(Ext.getCmp('phoneNumber').getValue());
            	Ext.getCmp('bPostalCode').setValue(Ext.getCmp('postalCode').getValue());
            	Ext.getCmp('bCity').setValue(Ext.getCmp('city').getValue());
            	Ext.getCmp('bCountry').setValue(Ext.getCmp('country').getValue());
            }
			
			
        </script>
    </head>
    <body>
        <div id="franceCustomer"></div>
    </body>
</html>
